using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public static PlayerController Instance { get; private set; }

    public event EventHandler OnJumpAction;
    public event EventHandler OnAttackAction;
    public event EventHandler OnHookAction;
    public event EventHandler OnPauseAction;

    /*[HideInInspector]
    public float v;*/
    //[HideInInspector]
    //public bool jump;
    /*[HideInInspector]
    public bool hook;*/
    /*[HideInInspector]
    public bool attack;*/

    private PlayerInputActions playerInputActions;


    private void Awake()
    {
        Instance = this;
        playerInputActions = new PlayerInputActions();
        playerInputActions.Player.Enable();
        playerInputActions.Player.Jump.performed += Jump_performed;
        playerInputActions.Player.Attack.performed += Attack_performed;
        playerInputActions.Player.Hoook.performed += Hoook_performed;
        playerInputActions.Player.Pause.performed += Pause_performed;
    }

    private void Pause_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        OnPauseAction?.Invoke(this, EventArgs.Empty);
    }

    private void Hoook_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        OnHookAction?.Invoke(this, EventArgs.Empty);
    }

    private void Attack_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        OnAttackAction?.Invoke(this, EventArgs.Empty);
    }

    private void Jump_performed(UnityEngine.InputSystem.InputAction.CallbackContext obj)
    {
        OnJumpAction?.Invoke(this, EventArgs.Empty);
    }



    public float GetInputAxisValue()
    {
        float h = playerInputActions.Player.Move.ReadValue<float>();
        return h;
    }



    
    /*void Update()
    {
#if UNITY_ANDROID
        h = VirtualContorller.GetAxis(ButtonType.horizontal); 
        
        jump = VirtualContorller.GetButtonDown(ButtonType.jump);

        attack = VirtualContorller.GetButtonDown(ButtonType.attack);

        hook = VirtualContorller.GetButtonDown(ButtonType.hook);
#endif
#if UNITY_STANDALONE_WIN


        
#endif
    }*/
}
